package com.hui.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hui.entity.dao.UserBill;
import com.hui.entity.enums.BillEnum;
import com.hui.mapper.UserBillMapper;
import com.hui.service.UserBillService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 用户账单表(UserBill)表服务实现类
 *
 * @author hui
 * @since 2022-07-27 14:46:10
 */
@Service("userBillService")
@RequiredArgsConstructor
public class UserBillServiceImpl extends ServiceImpl<UserBillMapper, UserBill> implements UserBillService {
    private final UserBillMapper yxUserBillMapper;

    public void expend(Long uid, String title, String category, String type, double number, double balance, String mark) {
        UserBill userBill = UserBill.builder()
                .uid(uid)
                .title(title)
                .category(category)
                .type(type)
                .number(BigDecimal.valueOf(number))
                .balance(BigDecimal.valueOf(balance))
                .mark(mark)
                .pm(BillEnum.PM_0.getValue())
                .createTime(new Date())
                .build();
        this.yxUserBillMapper.insert(userBill);
    }

    public void income(Long uid, String title, String category, String type, double number, double balance, String mark, String linkid) {
        UserBill userBill = UserBill.builder().uid(uid).title(title).category(category).type(type).number(BigDecimal.valueOf(number)).balance(BigDecimal.valueOf(balance)).mark(mark).pm(BillEnum.PM_1.getValue()).linkId(linkid).build();
        this.yxUserBillMapper.insert(userBill);
    }
}

